<?php

App::uses('AppModel', 'Model');

/**
 * Ordersproduct Model
 *
 * @property Products $Products
 * @property Orders $Orders
 */
class Ordersproduct extends AppModel {

    /**
     * Validation rules
     *
     * @var array
     */
    public $validate = array(
        'products_id' => array(
            'numeric' => array(
                'rule' => array('numeric'),
            //'message' => 'Your custom message here',
            //'allowEmpty' => false,
            //'required' => false,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'orders_id' => array(
            'numeric' => array(
                'rule' => array('numeric'),
            //'message' => 'Your custom message here',
            //'allowEmpty' => false,
            //'required' => false,
            //'last' => false, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
        ),
        'orderQty' => array(
            'qty-1' => array(
                'rule' => array('numeric'),
                'message' => 'Numbers only please',
                //'allowEmpty' => false,
                //'required' => false,
                //'last' => true, // Stop validation after this rule
                //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
            'qty-2' => array(
                'rule' => array('range', 0, 1000),
                'message' => 'Please enter a number between 0 and 1000',
            ),
        ),
        'deliveredQty' => array(
            'dqty-1' => array(
                'rule' => array('numeric'),
                'message' => 'Numbers only please',
                //'allowEmpty' => false,
                //'required' => false,
                //'last' => true, // Stop validation after this rule
            //'on' => 'create', // Limit validation to 'create' or 'update' operations
            ),
            'dqty-2' => array(
                'rule' => array('range', 0, 1000),
                'message' => 'Please enter a number between 0 and 1000',
            ),
        ),
    );

    //The Associations below have been created with all possible keys, those that are not needed can be removed

    /**
     * belongsTo associations
     *
     * @var array
     */
    public $belongsTo = array(
        'Products' => array(
            'className' => 'Products',
            'foreignKey' => 'products_id',
            'conditions' => '',
            'fields' => '',
            'order' => ''
        ),
        'Orders' => array(
            'className' => 'Orders',
            'foreignKey' => 'orders_id',
            'conditions' => '',
            'fields' => '',
            'order' => ''
        )
    );

}
